package org.walkerljl.commons.invoke.support;

import org.walkerljl.commons.invoke.PingService;
import org.walkerljl.commons.log.Logger;
import org.walkerljl.commons.log.LoggerFactory;
import org.walkerljl.commons.util.JSONUtils;

import java.util.List;
import java.util.Set;

/**
 * Ping service impl
 *
 * @author lijunlin
 */
public class PingServiceImpl implements PingService {

    private static final Logger LOGGER = LoggerFactory.getLogger(PingServiceImpl.class);

    @Override
    public String ping() {
        return "Pong";
    }

    @Override
    public String pingObjects(Object... params) {
        String response = String.format("Pong:%s.", JSONUtils.toJSONString(params));
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(response);
        }
        return response;
    }

    @Override
    public String ping(byte param) {
        return pingObjects(param);
    }

    @Override
    public String ping(short param) {
        return pingObjects(param);
    }

    @Override
    public String ping(int param) {
        return pingObjects(param);
    }

    @Override
    public String ping(long param) {
        return pingObjects(param);
    }

    @Override
    public String ping(float param) {
        return pingObjects(param);
    }

    @Override
    public String ping(double param) {
        return pingObjects(param);
    }

    @Override
    public String ping(char param) {
        return pingObjects(param);
    }

    @Override
    public String ping(boolean param) {
        return pingObjects(param);
    }

    @Override
    public String ping(String param) {
        return pingObjects(param);
    }

    @Override
    public String ping(Long param) {
        return pingObjects(param);
    }

    @Override
    public String ping(String param1, Long param2) {
        return pingObjects(new Object[]{param1, param2});
    }

    @Override
    public String pingLongList(List<Long> param) {
        return pingObjects(param);
    }

    @Override
    public String pingStringList(List<String> param) {
        return pingObjects(param);
    }

    @Override
    public String pingArray(String[] param) {
        return pingObjects(param);
    }

    @Override
    public String pingArray(Long[] param) {
        return pingObjects(param);
    }

    @Override
    public String ping(Set<String> param1, Set<Long> param2) {
        return pingObjects(param1, param2);
    }
}
